

const path = require('path');
const staticImg = path.join(__dirname, 'static');

function SensorbitUnoBlocks(Blockly) {
    var color_do = "#FF0000";



    //直流电机
    Blockly.Blocks.microbit_motor = {
        init:function(){
            this.setColour(color_do);
            this.appendDummyInput("")
            .appendField(new Blockly.FieldImage(staticImg+"/21.Motor-Module.svg", 84, 42))
            .appendField(Blockly.Msg.MICROBIT_MOTOR)
            .appendField(new Blockly.FieldDropdown([
                    ['P1', "pin1"],
                    ['P2', "pin2"],
                    ['P12', "pin12"],
                    ['P14', "pin14"],
                    ['P16', "pin16"],
            ]),"INA")
            .appendField(Blockly.Msg.MICROBIT_MOTORINB)
            .appendField(new Blockly.FieldDropdown([
                    ['P1', "pin1"],
                    ['P8', "pin8"],
                    ['P12', "pin12"],
                    ['P13', "pin13"],
                    ['P15', "pin15"],
            ]),"INB")
            this.appendDummyInput("")
            .appendField(Blockly.Msg.MICROBIT_DIRECTION)
            .appendField(new Blockly.FieldDropdown([
                [Blockly.Msg.MICROBIT_FORWARD, "forward"],
                [Blockly.Msg.MICROBIT_REVERSE, "reverse"],
            ]),"direction")
                this.appendValueInput("motorSpeed", Number)
                .appendField(Blockly.Msg.MICROBIT_SPEED)
            this.setPreviousStatement(true,null);
            this.setNextStatement(true,null);
            this.setTooltip('');
        }
    };


    return Blockly;
}

module.exports = SensorbitUnoBlocks;

